extends StatusInterface

var not_found_time:float = 0

# 此怪物只会左右移动，并且遇到障碍物会反转
func _physics_process(delta):
	owner.move_and_slide()
	if owner.is_on_wall() and owner.velocity.x > 5 * owner.max_speed:
		manage_node.to_death()
		return
		
	if not owner.is_on_floor():
		manage_node.to_fall()
		return

func _process(delta):
	owner.velocity.y += owner.gravity * delta
	if owner.look_something() == 2:
		owner.velocity.x = move_toward(owner.velocity.x, 10 * owner.max_speed * owner.direction, owner.acceleration * delta)
	else:
		# 累计未发现时间超过0.2秒，降低速度
		not_found_time += delta
		if not_found_time > 0.2:
			not_found_time = 0.0
			owner.velocity.x = move_toward(owner.velocity.x, 0.0, owner.acceleration * delta)
			manage_node.to_find()
			return
			
